﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>文档预览</title>
    <!-- Bootstrap -->
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet">
    <link href="/JqueryPlug/dtGrid/jquery.dtGrid.css" rel="stylesheet">
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="/CSS/Base/BaseClass.css?cssver=4" rel="stylesheet" />
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .panel {
            border-radius: 0;
        }
    </style>
</head>
<body>
    <div class="container-fluid" style="margin: 0; padding: 0;" ms-controller="WDVIEW">
        <div class="row" style="margin:0">
            <div class="col-xs-12" style="padding:0">
                <div class="panel panel-default" style="margin-bottom: 0;border:0">
                    <div class="panel-heading" style="border-bottom-width:0">文件名称{{modelData.Name}}</div>
                    <div class="panel-body mainbody" style="padding: 0;border-bottom:0">
                        <iframe marginwidth="0" class="tabiframe" width="100%" style="min-height: 650px" marginheight="0" frameborder="0" scrolling="no" id="main" name="main"></iframe>
                    </div>
                    <!--<div class="panel-footer" style=" margin-top: -5px;">文档大小:{{(modelData.FileSize/1024).toFixed(1)+'K'}}</div>-->
                </div>
            </div>
            <div class="col-xs-3" style="padding:0;display:none">
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active"><a href="#wdsm" aria-controls="wdsm" role="tab" data-toggle="tab">文档说明</a></li>
                    <li role="presentation"><a href="#wdpl" aria-controls="wdpl" role="tab" data-toggle="tab">评论<span class="badge" ms-if="FileList!=null&&FileList.size()>0">{{FileList.size()}}</span></a></li>
                </ul>
                <!-- Tab panes -->
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="wdsm" style="padding:20px">
                        <dl>
                            <dt>文件名</dt>
                            <dd>{{modelData.Name}}</dd>
                            <dt>创建人</dt>
                            <dd>{{ComFunJS.convertuser(modelData.CRUser) }}</dd>
                            <dt>创建时间</dt>
                            <dd>{{modelData.CRDate|date("yyyy-MM-dd")}}</dd>
                            <dt>下载次数</dt>
                            <dd>2</dd>
                        </dl>
                        <a href="#" class="btn btn-info">我要下载</a>
                    </div>
                    <div role="tabpanel" class="tab-pane" id="wdpl">
                        <div class="chat-widget" style="padding:20px">
                            <ul class="list-unstyled">
                                <li class="by-me Yan-comment" ms-repeat-el="FileList">
                                    <div class="avatar" style="float: left">
                                        <img alt="" ms-attr-src="'/Upload/TX/'+el.CRUser+'.jpg'" style="width:65px;height:65px" onerror="javascript: this.src = '/images/TX/default.png'">
                                    </div>
                                    <div class="chat-content">
                                        <div class="chat-meta">{{el.CRUserName}} <span style="float: right">{{el.CRDate|date("MM月dd日 HH:mm")}}</span></div>
                                        {{el.MSGContent}}
                                        <div class="clearfix"></div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        <div class="input-group" style="padding-left:30px;width:95%">
                            <input class="form-control" type="text" ms-keypress="jptj(event,$(this))" placeholder="此处添加批注(按Ctrl+Enter直接提交)" />
                            <span class="input-group-btn">
                                <button type="button" data-loading-text="正在保存..." class="btn  btn-info addTL" autocomplete="off" ms-on-click="AddPL($(this).parent().parent().find('input'))">
                                    添加批注
                                </button>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script>
        var fileId = ComFunJS.getQueryString("ID");
        var model = avalon.define({
            $id: "WDVIEW",
            modelData: {},
            FileList: [],
            GetFileInfo: function () {
                if (fileId) {
                    $.getJSON('/API/FTAPI.ashx?Action=GETFILEINFO', { P1: fileId }, function (resultData) {
                        if (resultData.ErrorMsg == "") {
                            model.modelData = resultData.Result;
                            model.FileList = resultData.Result1;
                            $("#main").attr("src", resultData.Result2);
                            if (resultData.Result2.indexOf(".pdf") > 0) {
                                location.href = resultData.Result2;
                            }
                            var w = $(".mainbody").width();
                            var h = $(".mainbody").height();
                        }
                    })
                }
            },
            AddPL: function (dom) {
                var plcontent = dom.val();
                if ($.trim(plcontent) == "") {
                    parent.ComFunJS.winwarning("请输入批注内容");
                    return;
                }
                $.post('/API/FTAPI.ashx?Action=ADDCOMENT', { "P1": plcontent, "MsgType": "QYWD", "MsgLYID": model.modelData.ID }, function (result) {
                    var result = $.parseJSON(result);
                    if (result.ErrorMsg == "") {
                        model.FileList.push(result.Result);
                        dom.val("")
                    }
                })
            },
            jptj: function (event, dom) {
                if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {
                    model.AddPL(dom);
                }
            }
        });
        avalon.ready(function () {
            model.GetFileInfo();
            $("body").height(document.body.clientHeight)
            $("#main").height(document.body.clientHeight + 20)
        })
    </script>
</body>
</html>